#include <iostream>
using namespace std;
#include "BinaryTree.cpp"
#include "Sort.cpp"

void TestBTree() {
    BTreeNode* root = CreateBinaryTree();
    printf("先序遍历: ");   PrevOrder(root);   printf("\n");
    printf("中序遍历: ");   InOrder(root);     printf("\n");
    printf("后序遍历: ");   PostOrder(root);   printf("\n");
    printf("二叉树的结点数为: %d\n", BTreeSize(root));
    printf("二叉树的叶子结点数为: %d\n", BTreeLeafSize(root));
    printf("A结点的高度为: %d\n", BTreeNodeHight(root));
    printf("B结点的高度为: %d\n", BTreeNodeHight(root->_left));
    printf("C结点的高度为: %d\n", BTreeNodeHight(root->_right));
    printf("二叉树第1层的节点数为: %d\n", BTreeLevelKSize(root, 1));
    printf("二叉树第2层的节点数为: %d\n", BTreeLevelKSize(root, 2));
    printf("二叉树第3层的节点数为: %d\n", BTreeLevelKSize(root, 3));
    printf("二叉树第4层的节点数为: %d\n", BTreeLevelKSize(root, 4));
    printf("%c结点的左节点为: %c\n", BinaryTreeFind(root, 'B')->_data, BinaryTreeFind(root, 'B')->_left->_data);
    printf("%c结点的右节点为: %c\n", BinaryTreeFind(root, 'B')->_data, BinaryTreeFind(root, 'B')->_right->_data);
    printf("层序遍历: ");   BTreeLevelOrdef(root);   printf("\n");
    if(BinaryTreeComplete(root)) { printf("是完全二叉树\n"); }
    else { printf("不是完全二叉树\n"); }
}

int main() {
	// TestBTree();
    int arr[] = {5, 2, 4, 6, 1, 3, 5, 8, 3, 8, 1, 5, 2, 4, 6, 1, 3, 5, 8, 3, 8, 1};
    CountSort(arr, sizeof(arr) / sizeof(int));
    // MergeSortNonR(arr, sizeof(arr)/sizeof(int));
    ArrayPrint(arr, sizeof(arr) / sizeof(int));
    //MergeSortFile("data.txt");
    system("pause");
}